<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE HTML>
<html>
  <head>
     <title>
		秒杀管理
	</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/bootstrap.min.css"  />
</head>
<script src="${pageContext.request.contextPath}/js/jquery-1.6.3.js"></script>
 <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
 $("#search").click(function(){
		if($("#searchcontent").val()==null||$("#searchcontent").val()==""){
			alert("请填写搜索关键字");
			return false;
		}
});
$("#pagea").click(function(){
		var page=$("#page").html();
		var pageNum=$("#pageNum").html();
		if(page==1){
		return false;
		}
		
});
$("#pagea2").click(function(){
		var page=$("#page").html();
		var pageNum=$("#pageNum").html();
		if(page==pageNum){
			return false;
		}
		
});
});
function update(id){
	if(confirm("是否要修改信息?")){
	var price=$("#price"+id).val();
	var num=$("#num"+id).val();
	var state=$("#state"+id).val();
	var path=$("#path").val();
	if(price==""||price==null||num==""||num==null||state==""||state==null){
	alert("不允许有空项!");
	return false;
	}
	$.post(path+"SeckillController/update.action",{"id":id,"countnum":num,"state":state,"price":price}
	,function(data){
		if(data==1){
		alert("修改成功!")
		location.reload();
		}else{
		alert("修改失败!")
		}
	});
	}
	
}
</script>
<body style="width: 100%;height: 100%">
    	<div style="margin-left: 70%">
    		<form action="${pageContext.request.contextPath}/commodity/searchComm.action?bs=5" method="post">
    		<input id="searchcontent" type="text" style="border:1px solid #FF7F00" placeholder="商品标题或品牌" name="search">
    		<input type="hidden" value="3" name="bs">
    		<input id="search" type="submit" value="搜索" style="background: #FF7F00;color:#fff;height: 30px;">
    		</form>
    	</div>
    	
    <c:if test="${slist!=null }">
    	<c:forEach items="${slist}" var="ck">
    		<div class="ckdiv">
    		<div style="display: block;height:10px;width:100%;text-align:center;">
    			${ck.title}
    		</div>
    		<div style="margin:9px 0 0 15px">
    		<img src="${pageContext.request.contextPath}/file/img/${ck.img}" style="height:81px;width: 81px;border:1px solid #aaa">
    		</div>
    		<div style="margin:10px 0 0 15px">
    			<span>开始时间:</span>
    			<br>
    			<span style="color:#FF6347">
    			<fmt:formatDate value="${ck.sdate}" pattern="yyyy年MM月dd日 HH:mm"/>
    			</span>
    		</div>
    		<div style="margin:10px 0 0 15px">
    			<span>结束时间:</span>
    			<br>
    			<span style="color:#FF6347">
    			<fmt:formatDate value="${ck.edate}" pattern="yyyy年MM月dd日 HH:mm"/>
    			</span>
    		</div>
    		<div style="margin:10px 0 0 25px">
    			<span>秒杀价格</span>
    			<br>
    			<input id="price${ck.id}" type="text" value="${ck.price}" style="width:60px;color:#FF6347">
    		</div>
    		<div style="margin:10px 0 0 25px">
    			<span>秒杀数量</span>
    			<br>
    			<input id="num${ck.id}" type="text" value="${ck.countnum}" style="width:60px;color:#FF6347">
    		</div>
    		<div style="margin: 10px 0 0 30px;">
    			<span>
    			上架状态
    			</span>
    			<br>
    			<c:if test="${ck.state==0}">
    			<select style="color:#FF6347" id="state${ck.id}">
    			<option value="0">已上架</option>
    			<option value="2">未上架</option>
    			</select>
    			</c:if>
    			<c:if test="${ck.state!=0}">
    			<select style="color:#FF6347" id="state${ck.id}">
    			<option  value="2">未上架</option>
    			<option value="0">已上架</option>
    			</select>
    			</c:if>
    		</div>
    		<div style="margin:0 0 0 40px">
    			<button style="height:40px;width:100px;color:#FF6347" onclick="return update(${ck.id})">确认修改</button>
    		</div>
    	</div>
    	</c:forEach>
    	</c:if>
    	<c:if test="${slist==null }">
    		<h3 style="margin-left: 43%">没有找到商品</h3>
    	</c:if>
    			   <!-- 翻页 -->
	      <div style="margin-left: 72%;margin-top: 3%" >
	      		<a id="pagea" style="color:#FF7F00" href="${pageContext.request.contextPath}/SeckillController/sysList.action?page=${page-1}">上一页</a>
	      		共<span id="pageNum">${pageNum }</span>页,
	      		当前第<span style="color:#FF7F00" id="page">${page+1}</span>页
	      		<a id="pagea2" style="color:#FF7F00" href="${pageContext.request.contextPath}/SeckillController/sysList.action?page=${page+1}">下一页</a>
	      </div>
    	<input type="hidden" value="${pageContext.request.contextPath}/" id="path">
 </body>
 <script type="text/javascript">

 </script>
   <style>
  .ckdiv div{
  display: inline-block;
  }
.ckdiv{
	width: 900px;height:110px;border:1px solid #aaa;margin:20px 0 0 150px;
}
 .shelvesbtn{
  width:70px;height:124px;float: left;
  background:red;text-align: center;margin-left:55px;
  padding-top: 10px;
  }
    .shelvesbtn:HOVER{
  background: #EE6A50;cursor: pointer;
  }
   .shelvesbtnhidden{
  width:70px;height:125px;float: left;
  background: #FF7F00;text-align: center;margin-left:55px;
 
  }
    .shelvesbtnhidden span{
    display: block;width:100%;height: 50%;padding-top:13px;
    }
    .shelvesbtnhidden span:HOVER{
  background: #FF0000;cursor: pointer;
  }
   </style>
</html>